package UDP;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class Send {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket();
        Scanner scanner = new Scanner(System.in);


        while (true){

            System.out.println("请写出你要说的话");
            String s = scanner.nextLine();

            if (s.equals("886")){
                break;
            }
            byte[] bytes = s.getBytes();

            InetAddress address = InetAddress.getByName("127.0.0.1");

            int port = 10086;

            DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length,address,port);

            datagramSocket.send(datagramPacket);


        }

        datagramSocket.close();
    }
}
